#include <VVertexCommon.h>

// material vertex code for mesh object.
#if MESH_SKINNED
struct VVertexInputDepthOnly 
{
	float4 Pos : POSITION;

#if VDEPTHONLY
	float4 texcoord_0 : TEXCOORD0;
#if	USE_INSTANCING
	float1 texcoord_5 : TEXCOORD2;
#endif 

#else 
	float4 texcoord_0 : TEXCOORD0;
	float4 texcoord_1 : TEXCOORD1;
	float4 texcoord_2 : TEXCOORD2;
	float4 texcoord_3 : TEXCOORD3;
	float4 texcoord_4 : TEXCOORD4;
	float1 texcoord_5 : TEXCOORD5;
#endif 
	
};

struct VVertexInput
{
	float4 Pos : POSITION;
	float4 texcoord_0 : TEXCOORD0;
	float4 texcoord_1 : TEXCOORD1;
	float4 texcoord_2 : TEXCOORD2;
	float4 texcoord_3 : TEXCOORD3;
	float4 texcoord_4 : TEXCOORD4;
	float1 texcoord_5 : TEXCOORD5;
};
#else // static mesh


struct VVertexInput
{
	float4	Pos : POSITION;			// local position
	float4	TexCoord : TEXCOORD0;
#if HAS_TANGENTSPACE
	half4	Tangent:TEXCOORD1;
	half3	Normal:NORMAL;
	half3	Binormal:TEXCOORD3;		// we store binormal . don't recalc in pixel shader
#else 
	half3	Normal:NORMAL;
#endif 

#if USE_INSTANCING
	float1 texcoord_3 : TEXCOORD3;
#endif 
};

#endif	// SKINMESH



struct VCommonV2F 
{
	float4 HPos : POSITION;
	float4 TexCoord : TEXCOORD0;
#if HAS_TANGENTSPACE
	half3 Tangent : TEXCOORD1;			// world to tangent basis
	half3 Binormal : TEXCOORD2;
	half3 Normal : TEXCOORD3;
#else 
	half3 Normal:TEXCOORD1;		// world space normal.
#endif 

#ifdef AMBIENT_LIGHT
	float4 texcoord_4 : TEXCOORD4;
#ifdef SHADOW && USE_TRANSLUCENT
	float4 texcoord_5 : TEXCOORD5;
#endif
#endif
#ifdef PAINT
	float3 texcoord_4 : TEXCOORD4;
#endif
#ifdef FLECK
	float3 texcoord_6 : TEXCOORD6;
#endif
#ifdef TRIPLANAR || OVERLAP
	float4 texcoord_6 : TEXCOORD6;
#endif
#ifdef PATCH
	float2 texcoord_6 : TEXCOORD6;
#endif
#ifdef USE_DEFERRED || USE_OCCLUSION || (USE_PARALLAX && PARALLAX) || (USE_ALPHA_FADE && ALPHA_FADE)
	float4 texcoord_7 : TEXCOORD7;
#endif
};

#include "mesh/VMeshVertexLib.h"



#if VPASS_DEPTHONLY


#elif VPASS_AMBIENT


VCommonV2F VGetVertexOutput(VVertexContext vCtx)
{
	VCommonV2F OUT = (VCommonV2F)0;
	OUT.HPos = vCtx.HPos;
	OUT.TexCoord = vCtx.TexCoord;

#if HAS_TANGENTSPACE
	OUT.Tangent = vCtx.Tangent;
	OUT.Binormal = vCtx.Binormal;
	OUT.Normal = vCtx.Normal
#else
	OUT.Normal = vCtx.Normal;
#endif 

#ifdef PAINT
	OUT.texcoord_4 = -mul3(s_imodelview,vertex.xyz);
#endif

#ifdef FLECK
	OUT.texcoord_6 = position.xyz;
#endif

#ifdef TRIPLANAR
	OUT.texcoord_0.xy = direction.xy;
	OUT.texcoord_6.xyz = position.xyz;
	OUT.texcoord_6.w = direction.z;
#endif

#ifdef OVERLAP
#ifdef GLOBAL
	OUT.texcoord_6.xyz = mul4(s_imodelview,vertex).xyz;
	OUT.texcoord_6.w = mul3(s_imodelview,normal).z;
#else
	OUT.texcoord_6.xyz = position.xyz;
	OUT.texcoord_6.w = direction.z;
#endif
#endif

#ifdef PATCH
	OUT.texcoord_6 = patch_parameters;
#endif

#ifdef USE_DEFERRED || USE_OCCLUSION || (USE_PARALLAX && PARALLAX) || (USE_ALPHA_FADE && ALPHA_FADE)
	OUT.texcoord_7 = getProjection(OUT.position);
#ifdef USE_ALPHA_FADE && ALPHA_FADE
	OUT.texcoord_7.z = getAlphaFade(bound_sphere);
#endif
#endif
	return OUT;
}

//VERTEX_OUT VAmbientVS(VVertexInput Input)
//{
//	VVertexContext vCtx = VInitVertexContext(Input);
//	VERTEX_OUT Out = (VERTEX_OUT)0;
//	Out.HPos = vCtx.HPos;
//
//}

#endif 

